<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        window.onload=function(){

            //获取DOM对象
            var d1=document.getElementById("d1");
            var d2=document.getElementById("d2");
            var d3=document.getElementById("d3");
            d1.onclick=function(){

                // console.log(this);//触发事件的元素，也称为事件源
                // console.log(d1.innerHTML);
                console.log(this.innerHTML);
            };
            d2.onclick=function(){
                // console.log(this);
                // console.log(d2.innerHTML);
                console.log(this.innerHTML);
            };
            d3.onclick=function(){
                // console.log(this);
                // console.log(d3.innerHTML);
                console.log(this.innerHTML);
            };
            
        };
    </script>
</head>
<body>
    <div id="d1">div1</div>
    <div id="d2">div2</div>
    <div id="d3">div3</div>
</body>
</html>